<?php
/*code here*/
/* Redirect user if they already logged */
if(!Auth::hasAuth('current_user')){
   $this->view->current_user = Auth::getAuth('current_user');
}
else{
   header('location: /');
}

/*code here(end)*/
$this->setLayout();

if(isset($_GET['id'])){
	$db = new Database;
	$id = functions::base_encode_decode("decrypt", $_GET['id']);
	$sqlStr = "SELECT * FROM tbuser WHERE id = {$db->escape($id)}  AND forgot_password=1";
	$validate = $db->query($sqlStr,"numrows");
	if($validate==1){
		$default_password = functions::encrypt_decrypt("encrypt","password");
		$update = array("password"=>$default_password,"forgot_password"=>0);
		$where = array("id"=>$id,"forgot_password"=>1);
		$update = $db->update("tbuser",$update,$where);
	}else{
		header('location: /');
	}
}else{
	header('location: /');
}
